<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@include file="/ui/jsp/includes/includes.jspf"%>
<%@include file="/ui/jsp/includes/noNavHeader.jspf"%>
<script type="text/javascript">
function saveChanges()
{	
		
		$('#firstTimeForm').attr('action', 'saveChanges.html');
		$('#firstTimeForm').submit();
	
}
$(document).ready(function() {
	$('#errorDiv').hide();
	
	$("#button1").click(function(){
		$('#errorDiv').empty();
		var errorFlag = false;
		
		if($('#password').val() != $('#confirmPassword').val()){
			errorFlag = true;
			$('#errorDiv').append("Password and Confirm Password are not the same.<br/>");
		}
		if($('#password').val() == "" || $('#password').val()==null){
			errorFlag = true;
			$('#errorDiv').append("Please enter a new password.<br/>");
		}
		if($('#securityQuestion').val() == "" || $('#securityQuestion').val()==null){
			errorFlag = true;
			$('#errorDiv').append("Please enter a security question.<br/>");
		}
		if($('#securityAnswer').val() == "" || $('#securityAnswer').val()==null){
			errorFlag = true;
			$('#errorDiv').append("Please enter a security answer.<br/>");
		}
		
		if(errorFlag==true)
    		$('#errorDiv').show();
    	if(errorFlag==false)
    	{
    		$('#errorDiv').hide();
        	saveChanges();
    	}
    });
});
</script>
<div class="hero-unit secondary_container">
	<form:form id="firstTimeForm" method="POST" commandName="userLogin"  cssClass="form-horizontal" onkeypress="if(event.keyCode == 13) {javascript:saveChanges();}">
		<div id="errorDiv" class="errorblock"></div>
		<div class="control-group">
			<label class="control-label" for="userName">UserName</label>
			<div class="controls">
				<form:label id="userName" path="userName">${userLogin.userName}</form:label>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputPassword">Password</label>
			<div class="controls">
				<form:password id="password" path="password"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputConfirmPassword">Confirm Password</label>
			<div class="controls">
				<input type="password" id="confirmPassword"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputSecurityQuestion">Security Question</label>
			<div class="controls"><form:input id="securityQuestion" path="securityQuestion"/></div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputSecurityAnswer">Security Answer</label>
			<div class="controls"><form:input id="securityAnswer" path="securityAnswer" autocomplete="off"/></div>
		</div>
		<div class="control-group">
			<div class="controls" tabindex="0">
				<!-- <button type="button" class="btn btn-primary">Forgot
					Password</button> -->
				<input type="button" id="button1" value="Submit" class="btn btn-primary"/>
			</div>
		</div>
		<form:hidden id="userLoginId" path="userLoginId" value="${userLogin.userLoginId}"/>
		<form:hidden id="userName" path="userName" value="${userLogin.userName}"/>
	</form:form>
</div>
<%@include file="/ui/jsp/includes/footer.jspf"%>
